package com.sgx.learning.luban.mybatis.xml;

import com.sgx.learning.luban.mybatis.pojo.OilTrend;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

public class Main {

    public static void main(String[] args) throws IOException {
        String resource = "mybatis/mybatis-config.xml";
        InputStream inputStream = Resources.getResourceAsStream(resource);
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
        SqlSession sqlSession = sqlSessionFactory.openSession();
        OilTrend res = (OilTrend) sqlSession.selectOne(
                "com.sgx.learning.luban.mybatis.mapper.OilTrendMapper.selectByPrimaryKey",
                13L);
        System.out.println("------");
    }
}
